package com.example.lotterysystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.lotterysystem.dao.dataobject.ActivityPrize;
import com.example.lotterysystem.dao.dataobject.ActivityUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityPrizeMapper extends BaseMapper<ActivityPrize> {
    @Insert("<script> insert into activity_prize (activity_id, prize_id, prize_amount, prize_tiers, status)" +
            " values <foreach collection = 'items' item = 'item' index = 'index' separator=','>" +
            " (#{item.activityId}, #{item.prizeId}, #{item.prizeAmount}, #{item.prizeTiers}, #{item.status})" +
            " </foreach>" + " </script>")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer batchInsert(@Param("items") List<ActivityPrize> activityPrizeList);

    @Update("update activity_prize set status = #{status} where activity_id = #{activityId} and prize_id = #{prizeId}")
    Integer updateStatus(@Param("activityId") Long activityId, @Param("prizeId") Long prizeId, @Param("status") String status);
}
